{extend name="base" /}

{block name="content"}
<script src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>
<!-- 引入 echarts.js -->
	<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
<div class="m-options cf">

	<div class="m-search fr">

		<form action="" class="layui-form" id="searchForm">

			<div class="store">
				<label for="">下单时间</label>

				<input type="text" name="start_time" class="u-ipt u-ipt-small start_time" placeholder="开始时间" value="{$startTime ?: ''}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly />

				<span>-</span>

				<input type="text" name="end_time" class="u-ipt u-ipt-small end_time" placeholder="结束时间" value="{$endTime ?: ''}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly />

				<input type="submit" class="u-btn u-search" value="查看" />
			</div>
		</form>

	</div>

</div>
	<div id="main" style="width: 600px;height:400px;"></div>
{/block}

{block name="extrajs"}

<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));
    var arr1=[],arr2=[],arr3=[];
    function arrTest(){
        var start_time = $('.start_time').val();
        var end_time = $('.end_time').val();
        $.ajax({
            type:"post",
            async:false,
            url:"/manage/data_chart/orderValue",
            data:{start_time:start_time,end_time:end_time},
            dataType:"json",
            success:function(result){
				console.log(JSON.stringify(result))
                if (result) {
					arr1.push(result.legend_data);
					arr2.push(result.chartdate);
					arr3.push(result.seriess);
                }
            }
        })
        console.log(JSON.stringify(arr1))
        console.log(JSON.stringify(arr2))
        console.log(JSON.stringify(arr3))
        return arr1,arr2,arr3;
    }
    arrTest();
    var option = {
        title: {
            text: '订单统计'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data:arr1
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: arr2[0]
        },
        yAxis: {
            type: 'value'
        },
        series: arr3[0]

    };
    myChart.setOption(option);
</script>

{/block}

